using CfgTable;
using Cysharp.Threading.Tasks;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using NetProtocol.POD;
using System;
using System.Collections.Generic;

namespace IQIGame.Onigao.GamePlay
{
    public enum NoticeResultType
    {
        /// <summary>
        /// 无效/默认/未设置
        /// </summary>
        None,
        /// <summary>
        /// 玩家点击确定
        /// </summary>
        Confirm,
        /// <summary>
        /// 玩家点击取消
        /// </summary>
        Cancel,
        /// <summary>
        /// 玩家点击关闭
        /// </summary>
        Close,
        /// <summary>
        /// 系统内部取消，如UI被其他逻辑强制关闭
        /// </summary>
        CancelBySystem,
        /// <summary>
        /// 异常
        /// </summary>
        Exception
    }
    /// <summary>
    /// 通知Notice模块
    /// </summary>
    public class NoticeModule
    {
        /// <summary>
        /// 临时数组，避免额外GC，用于string.Format，最多只允许8个动态参数
        /// </summary>
        private static string[] _dynTextParams = new string[8];

        public static void ClearAll()
        {
            FloatNotice.Instance.Clear();
        }

        /// <summary>
        /// 错误码的内容提示
        /// </summary>
        public static void ShowErrorNotice(int code)
        {
            if (code > 0)
            {
                FloatNotice.Instance.ShowError(code);
            }
        }

        /// <summary>
        /// 优化过的通过动态参数格式化字符串方法
        /// 业务代码不开放动态参数，仅在最后需要string.Format时做一下优化，尽量避免GC（但实际上只要调用string.Format就至少会有一个alloc）
        /// </summary>
        /// <param name="text"></param>
        /// <param name="dynParams">1.在外部可使用ListPool，NoticeModule的接口目前保证在调用后，调用处可立即Release dynParams
        /// 2.类型是List<string>而不是List<object>，会导致调用NoticeModule的接口时，如果动态参数是int，需要ToString，会有一点点不方便，但可以避免一次装箱，否则装箱和ToString时都会有alloc
        /// 3.注意最多只允许8个动态字符串参数</param>
        /// <returns></returns>
        private static string FormatDynText(string text, List<string> dynParams)
        {
            if (dynParams == null || dynParams.Count == 0)
            {
                return text ?? string.Empty;
            }
#if UNITY_EDITOR
            if (dynParams.Count > _dynTextParams.Length)
            {
                LogGame.LogError($"动态参数长度大于{_dynTextParams.Length}，目前不支持，多余的参数会被忽略。请找核心程序商量对策后再做修改。");
            }
#endif
            //优化，策划在表里不填任何信息，完全通过动态参数赋值
            //少数系统级提示会这么做
            if (string.IsNullOrEmpty(text))
            {
                return dynParams[0];
            }
            int len = dynParams.Count;
            switch (len)
            {
                //长度小于4时，string.Format底层不会走动态参数，可以避免无意义的GC，实际上大多数情况下不会超过3个
                case 0:
                    return text;
                case 1:
                    return string.Format(text, dynParams[0]);
                case 2:
                    return string.Format(text, dynParams[0], dynParams[1]);
                case 3:
                    return string.Format(text, dynParams[0], dynParams[1], dynParams[2]);
                //长度大于等于4，通过一个固定的数组传入，避免动态参数创建数组
                default:
                    len = Math.Min(_dynTextParams.Length, dynParams.Count);
                    for (int i = 0; i < len; i++)
                    {
                        _dynTextParams[i] = dynParams[i];
                    }
                    return string.Format(text, _dynTextParams);
            }
        }

        #region 普通提示/确认 回调

        private static void InnerShowNotice(int cfgNoticeId, Action callConfirm, Action callCancel, Action callClose, List<string> tempDynParams)
        {
            var cfgNotice = TableCenter.notice.Get(cfgNoticeId);
            string finalDesc = tempDynParams == null ? cfgNotice.Describe : FormatDynText(cfgNotice.Describe, tempDynParams);
            switch (cfgNotice.Type)
            {
                case NoticeType.Float:
                    FloatNotice.Instance.Show(finalDesc);
                    break;
                case NoticeType.Runing:
                    break;
                case NoticeType.Chat:
                    break;
                case NoticeType.Confirm:
                    var d = UD_Confirm.Create(cfgNotice, finalDesc, callConfirm, callCancel, callClose);
                    ManagerCenter.UI.ShowWindow<UIConfirm>(d);
                    break;
                default:
                    LogGame.LogError($"不支持的类型, by id = {cfgNoticeId} , type = {cfgNotice.Type} ");
                    break;
            }
        }

        public static void ShowNotice(int cfgNoticeId, Action callConfirm)
        {
            InnerShowNotice(cfgNoticeId, callConfirm, null, null, null);
        }

        public static void ShowNotice(int cfgNoticeId, Action callConfirm, Action callCancel, Action callClose)
        {
            InnerShowNotice(cfgNoticeId, callConfirm, callCancel, callClose, null);
        }

        public static void ShowNotice(int cfgNoticeId, Action callConfirm, Action callCancel, Action callClose, string p1)
        {
            List<string> list = ListPool<string>.Get();
            list.Add(p1);
            InnerShowNotice(cfgNoticeId, callConfirm, callCancel, callClose, list);
            ListPool<string>.Put(list);
        }

        public static void ShowNotice(int cfgNoticeId, Action callConfirm, Action callCancel, Action callClose, string p1, string p2)
        {
            List<string> list = ListPool<string>.Get();
            list.Add(p1);
            list.Add(p2);
            InnerShowNotice(cfgNoticeId, callConfirm, callCancel, callClose, list);
            ListPool<string>.Put(list);
        }

        public static void ShowNotice(int cfgNoticeId, Action callConfirm, Action callCancel, Action callClose, string p1, string p2, string p3)
        {
            List<string> list = ListPool<string>.Get();
            list.Add(p1);
            list.Add(p2);
            list.Add(p3);
            InnerShowNotice(cfgNoticeId, callConfirm, callCancel, callClose, list);
            ListPool<string>.Put(list);
        }

        /// <summary>
        /// 普通提示/确认
        /// </summary>
        /// <param name="cfgNoticeId"></param>
        /// <param name="callConfirm"></param>
        /// <param name="callCancel"></param>
        /// <param name="callClose"></param>
        /// <param name="dynTextParams">注意最多只允许8个动态字符串参数</param>
        public static void ShowNotice(int cfgNoticeId, Action callConfirm, Action callCancel, Action callClose, List<string> dynTextParams)
        {
            InnerShowNotice(cfgNoticeId, callConfirm, callCancel, callClose, dynTextParams);
        }
        #endregion 普通提示/确认 回调

        #region 普通提示/确认 可等待
        public static UniTask<NoticeResultType> ShowNotice(int cfgNoticeId)
        {
            return InnerShowNotice(cfgNoticeId, null);
        }

        public static UniTask<NoticeResultType> ShowNotice(int cfgNoticeId, string p1)
        {
            List<string> list = ListPool<string>.Get();
            list.Add(p1);
            var task = InnerShowNotice(cfgNoticeId, list);
            ListPool<string>.Put(list);
            return task;
        }

        public static UniTask<NoticeResultType> ShowNotice(int cfgNoticeId, string p1, string p2)
        {
            List<string> list = ListPool<string>.Get();
            list.Add(p1);
            list.Add(p2);
            var task = InnerShowNotice(cfgNoticeId, list);
            ListPool<string>.Put(list);
            return task;
        }

        public static UniTask<NoticeResultType> ShowNotice(int cfgNoticeId, string p1, string p2, string p3)
        {
            List<string> list = ListPool<string>.Get();
            list.Add(p1);
            list.Add(p2);
            list.Add(p3);
            var task = InnerShowNotice(cfgNoticeId, list);
            ListPool<string>.Put(list);
            return task;
        }

        public static UniTask<NoticeResultType> ShowNotice(int cfgNoticeId, List<string> dynTextParams)
        {
            return InnerShowNotice(cfgNoticeId, dynTextParams);
        }

        private static async UniTask<NoticeResultType> InnerShowNotice(int cfgNoticeId, List<string> tempDynParams)
        {
            var cfgNotice = TableCenter.notice.Get(cfgNoticeId);
            string finalDesc = tempDynParams == null ? cfgNotice.Describe : FormatDynText(cfgNotice.Describe, tempDynParams);

            UIBaseWindow window = null;
            switch (cfgNotice.Type)
            {
                case NoticeType.Float:
                    FloatNotice.Instance.Show(finalDesc);
                    break;
                case NoticeType.Runing:
                    break;
                case NoticeType.Chat:
                    break;
                case NoticeType.Confirm:
                    await ManagerCenter.UI.ShowWindowAsync<UIConfirm>();
                    //注意，UIConfrim因为在UI内部模拟了多开，所以不能直接使用BaseNoticeEntityUI，这里特殊处理。
                    //如果不是这种特殊情况尽量使用BaseNoticeEntityUI
                    var awaitWindow = ManagerCenter.UI.GetEntityUI<UIConfirm>();
                    window = awaitWindow;
                    var d = UD_Confirm.Create(cfgNotice, finalDesc, null, null, null);
                    return await awaitWindow.PopWindow(d);
                default:
                    LogGame.LogError($"不支持的类型, by id = {cfgNoticeId} , type = {cfgNotice.Type} ");
                    break;
            }
            if (window != null && !window.isActive)
            {
                LogGame.LogError("窗口未打开？");
                return NoticeResultType.CancelBySystem;
            }
            //走到这里返回None的一定是既不需要等待也没有回调的UI，比如飘字
            return NoticeResultType.None;
        }
        #endregion 普通提示/确认 可等待

        #region 普通提示/确认, 不用传回调
        public static void ShowNoticeNoCall(int cfgNoticeId)
        {
            InnerShowNotice(cfgNoticeId, null, null, null, null);
        }

        public static void ShowNoticeNoCall(int cfgNoticeId, string p1)
        {
            ShowNotice(cfgNoticeId, null, null, null, p1);
        }

        public static void ShowNoticeNoCall(int cfgNoticeId, string p1, string p2)
        {
            ShowNotice(cfgNoticeId, null, null, null, p1, p2);
        }

        public static void ShowNoticeNoCall(int cfgNoticeId, string p1, string p2, string p3)
        {
            ShowNotice(cfgNoticeId, null, null, null, p1, p2, p3);
        }

        public static void ShowNoticeNoCall(int cfgNoticeId, List<string> dynTextParams)
        {
            ShowNotice(cfgNoticeId, null, null, null, dynTextParams);
        }
        #endregion 普通提示/确认, 不用传回调

        #region 道具确认框 回调
        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        public static void ShowCostConfirm(int noticeCid, int itemCid, int itemNum, Action callConfirm)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            ShowCostConfirm(noticeCid, list, callConfirm);
            ListPool<int>.Put(list);
        }

        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        public static void ShowCostConfirm(int noticeCid, int itemCid, int itemNum, Action callConfirm, string p1)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            ShowCostConfirm(noticeCid, list, callConfirm, p1);
            ListPool<int>.Put(list);
        }

        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        public static void ShowCostConfirm(int noticeCid, int itemCid, int itemNum, Action callConfirm, string p1, string p2)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            ShowCostConfirm(noticeCid, list, callConfirm, p1, p2);
            ListPool<int>.Put(list);
        }

        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p3"></param>
        public static void ShowCostConfirm(int noticeCid, int itemCid, int itemNum, Action callConfirm, string p1, string p2, string p3)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            ShowCostConfirm(noticeCid, list, callConfirm, p1, p2, p3);
            ListPool<int>.Put(list);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        public static void ShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm)
        {
            InnerShowCostConfirm(noticeCid, itemCidNums, callConfirm, null, null, null);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        public static void ShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm, string p1)
        {
            List<string> dynParam = ListPool<string>.Get();
            dynParam.Add(p1);
            InnerShowCostConfirm(noticeCid, itemCidNums, callConfirm, null, null, dynParam);
            ListPool<string>.Put(dynParam);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        public static void ShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm, string p1, string p2)
        {
            List<string> dynParam = ListPool<string>.Get();
            dynParam.Add(p1);
            dynParam.Add(p2);
            InnerShowCostConfirm(noticeCid, itemCidNums, callConfirm, null, null, dynParam);
            ListPool<string>.Put(dynParam);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p3"></param>
        public static void ShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm, string p1, string p2, string p3)
        {
            List<string> dynParam = ListPool<string>.Get();
            dynParam.Add(p1);
            dynParam.Add(p2);
            dynParam.Add(p3);
            InnerShowCostConfirm(noticeCid, itemCidNums, callConfirm, null, null, dynParam);
            ListPool<string>.Put(dynParam);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="dynTextParams">注意最多只允许8个动态字符串参数</param>
        public static void ShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm, List<string> dynTextParams)
        {
            InnerShowCostConfirm(noticeCid, itemCidNums, callConfirm, null, null, dynTextParams);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="dynTextParams">注意最多只允许8个动态字符串参数</param>
        public static void ShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm, Action callCancel, Action callClose, List<string> dynTextParams)
        {
            InnerShowCostConfirm(noticeCid, itemCidNums, callConfirm, callCancel, callClose, dynTextParams);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="callCancel"></param>
        /// <param name="callClose"></param>
        /// <param name="dynParams"></param>
        private static void InnerShowCostConfirm(int noticeCid, List<int> itemCidNums, Action callConfirm, Action callCancel, Action callClose, List<string> dynParams)
        {
            var cfgNotice = TableCenter.notice.Get(noticeCid);
            string finalDesc = dynParams == null ? cfgNotice.Describe : FormatDynText(cfgNotice.Describe, dynParams);
            var newList = ListPool<int>.Get();
            newList.AddRange(itemCidNums);
            var d = UD_ConfirmItem.Create(cfgNotice, finalDesc,
                newList, callConfirm, callCancel, callClose);

            switch (cfgNotice.Type)
            {
                case NoticeType.ConfirmItem:
                    ManagerCenter.UI.ShowWindow<UIConfirmItem>(d);
                    break;
                case NoticeType.ConfirmCost:
                    ManagerCenter.UI.ShowWindow<UIConfirmCost>(d);
                    break;
                default:
                    LogGame.LogError($"不支持的道具确认框类型, id = {noticeCid} , type = {cfgNotice.Type} ");
                    break;
            }
        }
        #endregion 道具确认框 回调

        #region 道具确认框 可等待
        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, int itemCid, int itemNum)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            var task = ShowCostConfirm(noticeCid, list);
            ListPool<int>.Put(list);
            return task;
        }

        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, int itemCid, int itemNum, string p1)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            var task = ShowCostConfirm(noticeCid, list, p1);
            ListPool<int>.Put(list);
            return task;
        }

        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, int itemCid, int itemNum, string p1, string p2)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            var task = ShowCostConfirm(noticeCid, list, p1, p2);
            ListPool<int>.Put(list);
            return task;
        }

        /// <summary>
        /// 展示道具确认框
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p3"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, int itemCid, int itemNum, string p1, string p2, string p3)
        {
            var list = ListPool<int>.Get();
            list.Add(itemCid);
            list.Add(itemNum);
            var task = ShowCostConfirm(noticeCid, list, p1, p2, p3);
            ListPool<int>.Put(list);
            return task;
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, List<int> itemCidNums)
        {
            return InnerShowCostConfirm(noticeCid, itemCidNums, null);
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, List<int> itemCidNums, string p1)
        {
            List<string> dynParam = ListPool<string>.Get();
            dynParam.Add(p1);
            var task = InnerShowCostConfirm(noticeCid, itemCidNums, dynParam);
            ListPool<string>.Put(dynParam);
            return task;
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, List<int> itemCidNums, string p1, string p2)
        {
            List<string> dynParam = ListPool<string>.Get();
            dynParam.Add(p1);
            dynParam.Add(p2);
            var task = InnerShowCostConfirm(noticeCid, itemCidNums, dynParam);
            ListPool<string>.Put(dynParam);
            return task;
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="p1"></param>
        /// <param name="p2"></param>
        /// <param name="p3"></param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, List<int> itemCidNums, string p1, string p2, string p3)
        {
            List<string> dynParam = ListPool<string>.Get();
            dynParam.Add(p1);
            dynParam.Add(p2);
            dynParam.Add(p3);
            var task = InnerShowCostConfirm(noticeCid, itemCidNums, dynParam);
            ListPool<string>.Put(dynParam);
            return task;
        }

        /// <summary>
        /// 展示道具确认框，注意itemCidNums会被克隆，外部可放心释放
        /// </summary>
        /// <param name="noticeCid"></param>
        /// <param name="itemCidNums"></param>
        /// <param name="callConfirm"></param>
        /// <param name="dynTextParams">注意最多只允许8个动态字符串参数</param>
        public static UniTask<NoticeResultType> ShowCostConfirm(int noticeCid, List<int> itemCidNums, List<string> dynTextParams)
        {
            return InnerShowCostConfirm(noticeCid, itemCidNums, dynTextParams);
        }

        private static async UniTask<NoticeResultType> InnerShowCostConfirm(int noticeCid, List<int> itemCidNums, List<string> dynParams)
        {
            var cfgNotice = TableCenter.notice.Get(noticeCid);
            string finalDesc = dynParams == null ? cfgNotice.Describe : FormatDynText(cfgNotice.Describe, dynParams);
            var newList = ListPool<int>.Get();
            newList.AddRange(itemCidNums);
            var d = UD_ConfirmItem.Create(cfgNotice, finalDesc,
                newList, null, null, null);

            BaseNoticeEntityUI window = null;
            switch (cfgNotice.Type)
            {
                case NoticeType.ConfirmItem:
                    await ManagerCenter.UI.ShowWindowAsync<UIConfirmItem>();
                    window = ManagerCenter.UI.GetEntityUI<UIConfirmItem>();
                    break;
                case NoticeType.ConfirmCost:
                    await ManagerCenter.UI.ShowWindowAsync<UIConfirmCost>();
                    window = ManagerCenter.UI.GetEntityUI<UIConfirmCost>();
                    break;
                default:
                    LogGame.LogError($"不支持的道具确认框类型, id = {noticeCid} , type = {cfgNotice.Type} ");
                    return NoticeResultType.None;
            }
            if (!window.isActive)
            {
                LogGame.LogError("窗口未打开？");
                return NoticeResultType.CancelBySystem;
            }
            return await window.PopWindow(d);
        }
        #endregion 道具确认框 可等待

        /// <summary>
        /// 显示获得道具飘字
        /// </summary>
        /// <param name="itemCid"></param>
        /// <param name="itemNum"></param>
        public static void ShowNoticeFloatItem(int itemCid, int itemNum)
        {
            ManagerCenter.UI.ShowWindow<UIFloatNoticeItem>(UD_FloatNoticeItem.Create(itemCid, itemNum));
        }

        /// <summary>
        /// 获得物品界面展示
        /// </summary>
        public static void ShowUIItemGet(List<ItemShowPOD> list)
        {
            if (list == null || list.Count == 0)
            {
                return;
            }
            ManagerCenter.UI.ShowWindow<UIItemGet>(UD_ItemGet.Create(list));
        }
    }
}
